package cn.edu.hhu.servlet.admin;

import cn.edu.hhu.service.AdminService;
import cn.edu.hhu.service.Impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @anthor: lddd
 * @date: 2020/5/17 - 15:24
 * @description:
 **/
@WebServlet("/admin/changeTeacherPasswordServlet")
public class ChangeTeacherPasswordServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1获取id
        String tid = request.getParameter("tid");
        String newPassword = request.getParameter("newPassword");
        //2调用service删除
        AdminService adminService = new AdminServiceImpl();
        //System.out.println(sid+"   "+newPassword);
        adminService.modifyTeacherPassword(tid,newPassword);
        //3跳转到查询所有的servlet
        response.sendRedirect(request.getContextPath()+"/admin/queryAllTeacherServlet");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
